<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
<meta name="viewport" content="width=device-width">
<meta name="theme-color" content="#222"><meta name="generator" content="Hexo 6.3.0">

  <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png">
  <link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32-next.png">
  <link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16-next.png">
  <link rel="mask-icon" href="/images/logo.svg" color="#222">

<link rel="stylesheet" href="/css/main.css">



<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.2.1/css/all.min.css" integrity="sha256-Z1K5uhUaJXA7Ll0XrZ/0JhX4lAtZFpT6jkKrEDT0drU=" crossorigin="anonymous">
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/3.1.1/animate.min.css" integrity="sha256-PR7ttpcvz8qrF57fur/yAx1qXMFJeJFiA6pSzWi0OIE=" crossorigin="anonymous">

<script class="next-config" data-name="main" type="application/json">{"hostname":"example.com","root":"/","images":"/images","scheme":"Muse","darkmode":false,"version":"8.14.1","exturl":false,"sidebar":{"position":"left","display":"post","padding":18,"offset":12},"copycode":{"enable":false,"style":null},"bookmark":{"enable":false,"color":"#222","save":"auto"},"mediumzoom":false,"lazyload":false,"pangu":false,"comments":{"style":"tabs","active":null,"storage":true,"lazyload":false,"nav":null},"stickytabs":false,"motion":{"enable":true,"async":false,"transition":{"menu_item":"fadeInDown","post_block":"fadeIn","post_header":"fadeInDown","post_body":"fadeInDown","coll_header":"fadeInLeft","sidebar":"fadeInUp"}},"prism":false,"i18n":{"placeholder":"搜索...","empty":"没有找到任何搜索结果：${query}","hits_time":"找到 ${hits} 个搜索结果（用时 ${time} 毫秒）","hits":"找到 ${hits} 个搜索结果"},"path":"/search.xml","localsearch":{"enable":true,"trigger":"auto","top_n_per_article":-1,"unescape":false,"preload":false}}</script><script src="/js/config.js"></script>

    <meta name="description" content="系统平台信息OS:  Linux Mint 20.3 Una Kernel Release: 5.13.0-35-generic Hardware Platform: x86_64 CPU Model Name:  Intel(R) Xeon(R) CPU E5-2680 v3 @ 2.50GHz CPU Cores: 48 Main Memory: 125GB IP: 211.87.224.23">
<meta property="og:type" content="article">
<meta property="og:title" content="安装Docker、Harbor、Jenkins、Gitlab">
<meta property="og:url" content="http://example.com/2022/05/06/Sdu-Devops-01/index.html">
<meta property="og:site_name" content="JsyBlog">
<meta property="og:description" content="系统平台信息OS:  Linux Mint 20.3 Una Kernel Release: 5.13.0-35-generic Hardware Platform: x86_64 CPU Model Name:  Intel(R) Xeon(R) CPU E5-2680 v3 @ 2.50GHz CPU Cores: 48 Main Memory: 125GB IP: 211.87.224.23">
<meta property="og:locale" content="zh_CN">
<meta property="article:published_time" content="2022-05-06T13:00:00.000Z">
<meta property="article:modified_time" content="2023-04-04T17:48:17.995Z">
<meta property="article:author" content="SongyangJi">
<meta name="twitter:card" content="summary">


<link rel="canonical" href="http://example.com/2022/05/06/Sdu-Devops-01/">



<script class="next-config" data-name="page" type="application/json">{"sidebar":"","isHome":false,"isPost":true,"lang":"zh-CN","comments":true,"permalink":"http://example.com/2022/05/06/Sdu-Devops-01/","path":"2022/05/06/Sdu-Devops-01/","title":"安装Docker、Harbor、Jenkins、Gitlab"}</script>

<script class="next-config" data-name="calendar" type="application/json">""</script>
<title>安装Docker、Harbor、Jenkins、Gitlab | JsyBlog</title>
  








  <noscript>
    <link rel="stylesheet" href="/css/noscript.css">
  </noscript>
</head>

<body itemscope itemtype="http://schema.org/WebPage" class="use-motion">
  <div class="headband"></div>

  <main class="main">
    <div class="column">
      <header class="header" itemscope itemtype="http://schema.org/WPHeader"><div class="site-brand-container">
  <div class="site-nav-toggle">
    <div class="toggle" aria-label="切换导航栏" role="button">
        <span class="toggle-line"></span>
        <span class="toggle-line"></span>
        <span class="toggle-line"></span>
    </div>
  </div>

  <div class="site-meta">

    <a href="/" class="brand" rel="start">
      <i class="logo-line"></i>
      <p class="site-title">JsyBlog</p>
      <i class="logo-line"></i>
    </a>
  </div>

  <div class="site-nav-right">
    <div class="toggle popup-trigger" aria-label="搜索" role="button">
        <i class="fa fa-search fa-fw fa-lg"></i>
    </div>
  </div>
</div>



<nav class="site-nav">
  <ul class="main-menu menu"><li class="menu-item menu-item-home"><a href="/" rel="section"><i class="fa fa-home fa-fw"></i>首页</a></li><li class="menu-item menu-item-tags"><a href="/tags/" rel="section"><i class="fa fa-tags fa-fw"></i>标签</a></li><li class="menu-item menu-item-categories"><a href="/categories/" rel="section"><i class="fa fa-th fa-fw"></i>分类</a></li><li class="menu-item menu-item-archives"><a href="/archives/" rel="section"><i class="fa fa-archive fa-fw"></i>归档</a></li>
      <li class="menu-item menu-item-search">
        <a role="button" class="popup-trigger"><i class="fa fa-search fa-fw"></i>搜索
        </a>
      </li>
  </ul>
</nav>



  <div class="search-pop-overlay">
    <div class="popup search-popup"><div class="search-header">
  <span class="search-icon">
    <i class="fa fa-search"></i>
  </span>
  <div class="search-input-container">
    <input autocomplete="off" autocapitalize="off" maxlength="80"
           placeholder="搜索..." spellcheck="false"
           type="search" class="search-input">
  </div>
  <span class="popup-btn-close" role="button">
    <i class="fa fa-times-circle"></i>
  </span>
</div>
<div class="search-result-container no-result">
  <div class="search-result-icon">
    <i class="fa fa-spinner fa-pulse fa-5x"></i>
  </div>
</div>

    </div>
  </div>

</header>
        
  
  <aside class="sidebar">

    <div class="sidebar-inner sidebar-nav-active sidebar-toc-active">
      <ul class="sidebar-nav">
        <li class="sidebar-nav-toc">
          文章目录
        </li>
        <li class="sidebar-nav-overview">
          站点概览
        </li>
      </ul>

      <div class="sidebar-panel-container">
        <!--noindex-->
        <div class="post-toc-wrap sidebar-panel">
            <div class="post-toc animated"><ol class="nav"><li class="nav-item nav-level-1"><a class="nav-link" href="#%E7%B3%BB%E7%BB%9F%E5%B9%B3%E5%8F%B0%E4%BF%A1%E6%81%AF"><span class="nav-number">1.</span> <span class="nav-text">系统平台信息</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#%E4%BE%9D%E8%B5%96"><span class="nav-number">2.</span> <span class="nav-text">依赖</span></a><ol class="nav-child"><li class="nav-item nav-level-2"><a class="nav-link" href="#Docker"><span class="nav-number">2.1.</span> <span class="nav-text">Docker</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#%E8%AE%BE%E7%BD%AE%E5%AD%98%E5%82%A8%E5%BA%93"><span class="nav-number">2.1.0.1.</span> <span class="nav-text">设置存储库</span></a></li></ol></li><li class="nav-item nav-level-3"><a class="nav-link" href="#Docker-Compose"><span class="nav-number">2.1.1.</span> <span class="nav-text">Docker-Compose</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#Go"><span class="nav-number">2.2.</span> <span class="nav-text">Go</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#Java"><span class="nav-number">2.3.</span> <span class="nav-text">Java</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#Maven"><span class="nav-number">2.4.</span> <span class="nav-text">Maven</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#Gitlab"><span class="nav-number">2.5.</span> <span class="nav-text">Gitlab</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#%E5%AE%89%E8%A3%85"><span class="nav-number">2.5.1.</span> <span class="nav-text">安装</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#%E9%85%8D%E7%BD%AE"><span class="nav-number">2.5.2.</span> <span class="nav-text">配置</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#%E5%90%AF%E5%8A%A8"><span class="nav-number">2.5.3.</span> <span class="nav-text">启动</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#%E4%BD%BF%E7%94%A8Gitlab"><span class="nav-number">2.5.4.</span> <span class="nav-text">使用Gitlab</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#New-project-gt-Create-blank-project"><span class="nav-number">2.5.4.1.</span> <span class="nav-text">[New project]-&gt;[Create blank project]</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#Mac%E9%85%8D%E7%BD%AEssh%E7%99%BB%E5%BD%95"><span class="nav-number">2.5.4.2.</span> <span class="nav-text">Mac配置ssh登录</span></a></li></ol></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#Jenkins"><span class="nav-number">2.6.</span> <span class="nav-text">Jenkins</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#%E5%AE%89%E8%A3%85-1"><span class="nav-number">2.6.1.</span> <span class="nav-text">安装</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#%E9%85%8D%E7%BD%AE-1"><span class="nav-number">2.6.2.</span> <span class="nav-text">配置</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#%E4%BF%AE%E6%94%B9%E9%95%9C%E5%83%8F%E6%BA%90"><span class="nav-number">2.6.3.</span> <span class="nav-text">修改镜像源</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#%E5%90%AF%E5%8A%A8-1"><span class="nav-number">2.6.4.</span> <span class="nav-text">启动</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#%E7%99%BB%E5%BD%95Jenkins"><span class="nav-number">2.6.5.</span> <span class="nav-text">登录Jenkins</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#%E7%AE%A1%E7%90%86%E6%8F%92%E4%BB%B6"><span class="nav-number">2.6.6.</span> <span class="nav-text">管理插件</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#%E5%85%A8%E5%B1%80%E9%85%8D%E7%BD%AE"><span class="nav-number">2.6.7.</span> <span class="nav-text">全局配置</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#Manage-Jenkins-gt-Global-Tool-Configuration"><span class="nav-number">2.6.7.1.</span> <span class="nav-text">[Manage Jenkins]-&gt;[Global Tool Configuration]</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#Manage-Jenkins-gt-Configure-System-gt-Publish-over-SSH"><span class="nav-number">2.6.7.2.</span> <span class="nav-text">[Manage Jenkins]-&gt;[Configure System]-&gt;[Publish over SSH]</span></a></li></ol></li><li class="nav-item nav-level-3"><a class="nav-link" href="#%E5%9C%A8Jenkins%E5%AE%B9%E5%99%A8%E5%86%85%E4%BD%BF%E7%94%A8docker"><span class="nav-number">2.6.8.</span> <span class="nav-text">在Jenkins容器内使用docker</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#Harbor"><span class="nav-number">2.7.</span> <span class="nav-text">Harbor</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#%E4%B8%8B%E8%BD%BD"><span class="nav-number">2.7.1.</span> <span class="nav-text">下载</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#%E5%AE%89%E8%A3%85-2"><span class="nav-number">2.7.2.</span> <span class="nav-text">安装</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#%E6%8B%89%E5%8F%96-x2F-%E6%8E%A8%E9%80%81%E9%95%9C%E5%83%8F"><span class="nav-number">2.7.3.</span> <span class="nav-text">拉取&#x2F;推送镜像</span></a></li></ol></li></ol></li></ol></div>
        </div>
        <!--/noindex-->

        <div class="site-overview-wrap sidebar-panel">
          <div class="site-author animated" itemprop="author" itemscope itemtype="http://schema.org/Person">
  <p class="site-author-name" itemprop="name">SongyangJi</p>
  <div class="site-description" itemprop="description"></div>
</div>
<div class="site-state-wrap animated">
  <nav class="site-state">
      <div class="site-state-item site-state-posts">
        <a href="/archives/">
          <span class="site-state-item-count">251</span>
          <span class="site-state-item-name">日志</span>
        </a>
      </div>
      <div class="site-state-item site-state-categories">
          <a href="/categories/">
        <span class="site-state-item-count">45</span>
        <span class="site-state-item-name">分类</span></a>
      </div>
      <div class="site-state-item site-state-tags">
          <a href="/tags/">
        <span class="site-state-item-count">109</span>
        <span class="site-state-item-name">标签</span></a>
      </div>
  </nav>
</div>

        </div>
      </div>
    </div>

    
  </aside>


    </div>

    <div class="main-inner post posts-expand">


  


<div class="post-block">
  
  

  <article itemscope itemtype="http://schema.org/Article" class="post-content" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="http://example.com/2022/05/06/Sdu-Devops-01/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.gif">
      <meta itemprop="name" content="SongyangJi">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="JsyBlog">
      <meta itemprop="description" content="">
    </span>

    <span hidden itemprop="post" itemscope itemtype="http://schema.org/CreativeWork">
      <meta itemprop="name" content="安装Docker、Harbor、Jenkins、Gitlab | JsyBlog">
      <meta itemprop="description" content="">
    </span>
      <header class="post-header">
        <h1 class="post-title" itemprop="name headline">
          安装Docker、Harbor、Jenkins、Gitlab
        </h1>

        <div class="post-meta-container">
          <div class="post-meta">
    <span class="post-meta-item">
      <span class="post-meta-item-icon">
        <i class="far fa-calendar"></i>
      </span>
      <span class="post-meta-item-text">发表于</span>

      <time title="创建时间：2022-05-06 21:00:00" itemprop="dateCreated datePublished" datetime="2022-05-06T21:00:00+08:00">2022-05-06</time>
    </span>
    <span class="post-meta-item">
      <span class="post-meta-item-icon">
        <i class="far fa-calendar-check"></i>
      </span>
      <span class="post-meta-item-text">更新于</span>
      <time title="修改时间：2023-04-05 01:48:17" itemprop="dateModified" datetime="2023-04-05T01:48:17+08:00">2023-04-05</time>
    </span>
    <span class="post-meta-item">
      <span class="post-meta-item-icon">
        <i class="far fa-folder"></i>
      </span>
      <span class="post-meta-item-text">分类于</span>
        <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
          <a href="/categories/DevOps/" itemprop="url" rel="index"><span itemprop="name">DevOps</span></a>
        </span>
    </span>

  
</div>

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">
        <h1 id="系统平台信息"><a href="#系统平台信息" class="headerlink" title="系统平台信息"></a>系统平台信息</h1><p>OS:  Linux Mint 20.3 Una</p>
<p>Kernel Release: 5.13.0-35-generic</p>
<p>Hardware Platform: x86_64</p>
<p>CPU Model Name:  Intel(R) Xeon(R) CPU E5-2680 v3 @ 2.50GHz</p>
<p>CPU Cores: 48</p>
<p>Main Memory: 125GB</p>
<p>IP: 211.87.224.233</p>
<h1 id="依赖"><a href="#依赖" class="headerlink" title="依赖"></a>依赖</h1><h2 id="Docker"><a href="#Docker" class="headerlink" title="Docker"></a>Docker</h2><p>version 20.10.14</p>
<p>旧版本的 Docker </p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">sudo apt-get remove docker docker-engine docker.io containerd runc</span><br></pre></td></tr></table></figure>



<h4 id="设置存储库"><a href="#设置存储库" class="headerlink" title="设置存储库"></a>设置存储库</h4><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line">sudo apt-get update</span><br><span class="line"></span><br><span class="line">sudo apt-get install \</span><br><span class="line">    ca-certificates \</span><br><span class="line">    curl \</span><br><span class="line">    gnupg \</span><br><span class="line">    lsb-release</span><br></pre></td></tr></table></figure>



<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">sudo apt-get update</span><br></pre></td></tr></table></figure>



<p>这里没有安装 docker-compose</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">sudo apt-get install docker-ce docker-ce-cli containerd.io</span><br></pre></td></tr></table></figure>



<p>apt-cache madison docker-ce</p>
<p>version &#x3D; <code>5:20.10.16~3-0~ubuntu-focal</code></p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">sudo apt-get install docker-ce=5:20.10.16~3-0~ubuntu-focal docker-ce-cli=5:20.10.16~3-0~ubuntu-focal containerd.io</span><br></pre></td></tr></table></figure>





<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line">#1.配置阿里云的gpg</span><br><span class="line">curl -fsSL https://mirrors.aliyun.com/docker-ce/linux/ubuntu/gpg | sudo apt-key add -</span><br><span class="line"></span><br><span class="line">#2.配置阿里云的docker镜像</span><br><span class="line">sudo add-apt-repository &quot;deb [arch=amd64] https://mirrors.aliyun.com/docker-ce/linux/ubuntu $(lsb_release -cs) stable&quot;</span><br><span class="line"></span><br><span class="line">#3.执行安装命令</span><br><span class="line">sudo apt-get install docker-ce docker-ce-cli containerd.io</span><br></pre></td></tr></table></figure>






<h3 id="Docker-Compose"><a href="#Docker-Compose" class="headerlink" title="Docker-Compose"></a>Docker-Compose</h3><p>docker-compose version 1.29.2</p>
<p>安装</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">sudo curl -L &quot;https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)&quot; -o /usr/bin/docker-compose</span><br></pre></td></tr></table></figure>

<p>加上可执行权限</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">sudo chmod +x /usr/bin/docker-compose</span><br></pre></td></tr></table></figure>



<h2 id="Go"><a href="#Go" class="headerlink" title="Go"></a>Go</h2><p>go version go1.17.7 linux&#x2F;amd6</p>
<h2 id="Java"><a href="#Java" class="headerlink" title="Java"></a>Java</h2><p>openjdk version “1.8.0_312”</p>
<p>path: &#x2F;usr&#x2F;lib&#x2F;jvm&#x2F;java-8-openjdk-amd64</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">sudo update-alternatives --config java</span><br></pre></td></tr></table></figure>

<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_">#</span><span class="language-bash">output</span></span><br><span class="line">There are 3 choices for the alternative java (providing /usr/bin/java).</span><br><span class="line"></span><br><span class="line">  Selection    Path                                            Priority   Status</span><br><span class="line">------------------------------------------------------------</span><br><span class="line">* 0            /usr/lib/jvm/java-17-openjdk-amd64/bin/java      1711      auto mode</span><br><span class="line">  1            /usr/lib/jvm/java-11-openjdk-amd64/bin/java      1111      manual mode</span><br><span class="line">  2            /usr/lib/jvm/java-17-openjdk-amd64/bin/java      1711      manual mode</span><br><span class="line">  3            /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java   1081      manual mode</span><br><span class="line"></span><br><span class="line">Press &lt;enter&gt; to keep the current choice[*], or type selection number:</span><br></pre></td></tr></table></figure>

<p><code>java -version</code> 检查</p>
<h2 id="Maven"><a href="#Maven" class="headerlink" title="Maven"></a>Maven</h2><p>Apache Maven 3.8.5</p>
<p>path: &#x2F;opt&#x2F;apache-maven-3.8.5</p>
<ul>
<li>jdk8编译插件配置</li>
</ul>
<figure class="highlight xml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br></pre></td><td class="code"><pre><span class="line"><span class="tag">&lt;<span class="name">profile</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;<span class="name">id</span>&gt;</span>jdk-8<span class="tag">&lt;/<span class="name">id</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;<span class="name">activation</span>&gt;</span></span><br><span class="line">            <span class="tag">&lt;<span class="name">activeByDefault</span>&gt;</span>true<span class="tag">&lt;/<span class="name">activeByDefault</span>&gt;</span></span><br><span class="line">            <span class="tag">&lt;<span class="name">jdk</span>&gt;</span>8<span class="tag">&lt;/<span class="name">jdk</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;/<span class="name">activation</span>&gt;</span></span><br><span class="line"></span><br><span class="line">        <span class="tag">&lt;<span class="name">properties</span>&gt;</span></span><br><span class="line">            <span class="tag">&lt;<span class="name">maven.compiler.source</span>&gt;</span>8<span class="tag">&lt;/<span class="name">maven.compiler.source</span>&gt;</span></span><br><span class="line">            <span class="tag">&lt;<span class="name">maven.compiler.target</span>&gt;</span>8<span class="tag">&lt;/<span class="name">maven.compiler.target</span>&gt;</span></span><br><span class="line">            <span class="tag">&lt;<span class="name">maven.compiler.compilerVersion</span>&gt;</span>8<span class="tag">&lt;/<span class="name">maven.compiler.compilerVersion</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;/<span class="name">properties</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;/<span class="name">profile</span>&gt;</span></span><br></pre></td></tr></table></figure>



<ul>
<li>maven仓库源</li>
</ul>
<figure class="highlight xml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line"><span class="tag">&lt;<span class="name">mirror</span>&gt;</span></span><br><span class="line">   <span class="tag">&lt;<span class="name">id</span>&gt;</span>alimaven<span class="tag">&lt;/<span class="name">id</span>&gt;</span></span><br><span class="line">   <span class="tag">&lt;<span class="name">mirrorOf</span>&gt;</span>central<span class="tag">&lt;/<span class="name">mirrorOf</span>&gt;</span></span><br><span class="line">   <span class="tag">&lt;<span class="name">name</span>&gt;</span>Aliyun maven<span class="tag">&lt;/<span class="name">name</span>&gt;</span></span><br><span class="line">   <span class="tag">&lt;<span class="name">url</span>&gt;</span>https://maven.aliyun.com/repository/central<span class="tag">&lt;/<span class="name">url</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;/<span class="name">mirror</span>&gt;</span></span><br></pre></td></tr></table></figure>





<h2 id="Gitlab"><a href="#Gitlab" class="headerlink" title="Gitlab"></a>Gitlab</h2><p>使用docker安装 Gitlab</p>
<h3 id="安装"><a href="#安装" class="headerlink" title="安装"></a>安装</h3><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">docker search gitlab/</span><br></pre></td></tr></table></figure>


<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">docker pull gitlab/gitlab-ce:latest</span><br></pre></td></tr></table></figure>

<h3 id="配置"><a href="#配置" class="headerlink" title="配置"></a>配置</h3><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">sudo mkdir -p /srv/gitlab &amp;&amp; echo &quot;export GITLAB_HOME=/srv/gitlab&quot; &gt;&gt; .profile &amp;&amp; source .profile</span><br></pre></td></tr></table></figure>



<p>docker-compose.yml</p>
<figure class="highlight yaml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br></pre></td><td class="code"><pre><span class="line"><span class="attr">version:</span> <span class="string">&#x27;3.6&#x27;</span></span><br><span class="line"><span class="attr">services:</span> </span><br><span class="line">  <span class="attr">web:</span> </span><br><span class="line">    <span class="attr">image:</span> <span class="string">&#x27;gitlab/gitlab-ce:latest&#x27;</span></span><br><span class="line">    <span class="attr">container_name:</span> <span class="string">sdu-weblab-gitlab</span></span><br><span class="line">    <span class="attr">restart:</span> <span class="string">always</span></span><br><span class="line">    <span class="attr">hostname:</span> <span class="string">&#x27;211.87.224.233&#x27;</span></span><br><span class="line">    <span class="attr">environment:</span> </span><br><span class="line">      <span class="attr">GITLAB_OMNIBUS_CONFIG:</span> <span class="string">|</span></span><br><span class="line"><span class="string">        external_url &#x27;http://211.87.224.233:8929&#x27;</span></span><br><span class="line"><span class="string">        gitlab_rails[&#x27;gitlab_shell_ssh_port&#x27;] = 2224</span></span><br><span class="line"><span class="string"></span>    <span class="attr">ports:</span> </span><br><span class="line">      <span class="bullet">-</span> <span class="string">&#x27;8929:8929&#x27;</span></span><br><span class="line">      <span class="bullet">-</span> <span class="string">&#x27;2224:22&#x27;</span></span><br><span class="line">    <span class="attr">volumes:</span> </span><br><span class="line">      <span class="bullet">-</span> <span class="string">&#x27;$GITLAB_HOME/config:/etc/gitlab&#x27;</span></span><br><span class="line">      <span class="bullet">-</span> <span class="string">&#x27;$GITLAB_HOME/logs:/var/log/gitlab&#x27;</span></span><br><span class="line">      <span class="bullet">-</span> <span class="string">&#x27;$GITLAB_HOME/data:/var/opt/gitlab&#x27;</span></span><br></pre></td></tr></table></figure>

<p>注意点:</p>
<p>external_url中的端口需要和ports映射的容器端口保持一致;</p>
<p>gitlab_rails[‘gitlab_shell_ssh_port’]要和宿主机端口保持一致。</p>
<h3 id="启动"><a href="#启动" class="headerlink" title="启动"></a>启动</h3><p>构建并启动</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">docker-compose -f ./docker-compose.yml up -d # 如果文件名为`docker-compose.yml`可以不指定-f</span><br></pre></td></tr></table></figure>

<p>强制重启</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">docker-compose up -d --force-recreate</span><br></pre></td></tr></table></figure>



<p>重新构建并启动（反映yml的变化，一定是最新的）</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">docker-compose down &amp;&amp; docker-compose up -d</span><br></pre></td></tr></table></figure>





<p>注意：这个服务启动时间比较长，须等待一两分钟。</p>
<p>检查是否成功运行：浏览器访问 <a target="_blank" rel="noopener" href="http://211.87.224.233:8929/">http://211.87.224.233:8929</a>  (这个8989是映射的宿主机port，当然你可以映射成其他端口)</p>
<p>如果访问失败，注意云服务器的安全组或者firewall的端口开放情况（sudo ufw status）</p>
<h3 id="使用Gitlab"><a href="#使用Gitlab" class="headerlink" title="使用Gitlab"></a>使用Gitlab</h3><p>默认管理员账户：root</p>
<p>查看配置文件得到密码</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_"># </span><span class="language-bash">注意我们已经配置好数据卷映射了</span></span><br><span class="line">sudo cat $GITLAB_HOME/config/initial_root_password</span><br></pre></td></tr></table></figure>

<p>可以再去修改一下密码（设置为： sduweblab）</p>
<blockquote>
<p><a target="_blank" rel="noopener" href="https://docs.gitlab.com/ee/install/docker.html">https://docs.gitlab.com/ee/install/docker.html</a></p>
<p><a target="_blank" rel="noopener" href="https://gitlab.com/gitlab-org/omnibus-gitlab/blob/master/files/gitlab-config-template/gitlab.rb.template">https://gitlab.com/gitlab-org/omnibus-gitlab/blob/master/files/gitlab-config-template/gitlab.rb.template</a></p>
</blockquote>
<h4 id="New-project-gt-Create-blank-project"><a href="#New-project-gt-Create-blank-project" class="headerlink" title="[New project]-&gt;[Create blank project]"></a>[New project]-&gt;[Create blank project]</h4><h4 id="Mac配置ssh登录"><a href="#Mac配置ssh登录" class="headerlink" title="Mac配置ssh登录"></a>Mac配置ssh登录</h4><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">jisongyang@SongyangJi-MacBookAir .ssh % ssh -p 2224 -T git@211.87.224.233</span><br><span class="line">ssh: connect to host 211.87.224.233 port 2224: Connection refused</span><br></pre></td></tr></table></figure>



<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">jisongyang@SongyangJi-MacBookAir .ssh % ssh -T git@211.87.224.233</span><br><span class="line">git@211.87.224.233&#x27;s password:</span><br></pre></td></tr></table></figure>










<h2 id="Jenkins"><a href="#Jenkins" class="headerlink" title="Jenkins"></a>Jenkins</h2><h3 id="安装-1"><a href="#安装-1" class="headerlink" title="安装"></a>安装</h3><p>jenkins: 2.346</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">docker pull jenkins/jenkins:latest</span><br></pre></td></tr></table></figure>

<h3 id="配置-1"><a href="#配置-1" class="headerlink" title="配置"></a>配置</h3><p>docker-compse yml</p>
<figure class="highlight yaml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br></pre></td><td class="code"><pre><span class="line"><span class="attr">version:</span> <span class="string">&#x27;3.6&#x27;</span></span><br><span class="line"><span class="attr">services:</span> </span><br><span class="line">  <span class="attr">jenkins:</span> </span><br><span class="line">    <span class="attr">image:</span> <span class="string">jenkins/jenkins:latest</span></span><br><span class="line">    <span class="attr">container_name:</span> <span class="string">sdu-weblab-jenkins-latest</span></span><br><span class="line">    <span class="attr">restart:</span> <span class="string">always</span></span><br><span class="line">    <span class="attr">ports:</span> </span><br><span class="line">      <span class="bullet">-</span> <span class="string">&quot;18080:8080&quot;</span></span><br><span class="line">      <span class="bullet">-</span> <span class="string">&quot;50000:50000&quot;</span></span><br><span class="line">    <span class="attr">volumes:</span> </span><br><span class="line">      <span class="bullet">-</span> <span class="string">./data:/var/jenkins_home</span> <span class="comment"># jenkins:latest 的home目录，包括插件和配置等等</span></span><br><span class="line">      <span class="bullet">-</span> <span class="string">&#x27;$MAVEN_HOME:/opt/maven&#x27;</span></span><br><span class="line">      <span class="bullet">-</span> <span class="string">&#x27;$JAVA_HOME:/opt/java8&#x27;</span></span><br><span class="line">      <span class="bullet">-</span> <span class="string">/var/run/docker.sock:/var/run/docker.sock</span></span><br><span class="line">      <span class="bullet">-</span> <span class="string">/usr/bin/docker:/usr/bin/docker</span></span><br><span class="line">      <span class="bullet">-</span> <span class="string">/etc/docker/daemon.json:/etc/docker/daemon.json</span></span><br></pre></td></tr></table></figure>

<p>由于jenkins承担了打包的任务，因此将宿主机的jdk和maven挂载上去（另一种做法是自定义一个包含jdk和maven的jenkins镜像，有待尝试）。</p>
<p>(其中有关docker的配置后面再解释)</p>
<h3 id="修改镜像源"><a href="#修改镜像源" class="headerlink" title="修改镜像源"></a>修改镜像源</h3><p>否则大概率下载插件会失败！</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">vim data/hudson.model.UpdateCenter.xml</span><br></pre></td></tr></table></figure>



<figure class="highlight xml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">&lt;?xml version=&#x27;1.1&#x27; encoding=&#x27;UTF-8&#x27;?&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">sites</span>&gt;</span></span><br><span class="line">  <span class="tag">&lt;<span class="name">site</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">id</span>&gt;</span>default<span class="tag">&lt;/<span class="name">id</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">url</span>&gt;</span>https://mirrors.tuna.tsinghua.edu.cn/jenkins/updates/update-center.json<span class="tag">&lt;/<span class="name">url</span>&gt;</span></span><br><span class="line">  <span class="tag">&lt;/<span class="name">site</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;/<span class="name">sites</span>&gt;</span></span><br></pre></td></tr></table></figure>



<h3 id="启动-1"><a href="#启动-1" class="headerlink" title="启动"></a>启动</h3><p>启动之后，查看日志发现写数据卷的时候权限不够。（有可能）</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">sudo chmod -R 777 data/</span><br></pre></td></tr></table></figure>

<p>给足data文件夹权限。(奇怪的是，docker-compose restart的时候还是要发现写权限不够)</p>
<p>检查是否启动成功，访问 <a target="_blank" rel="noopener" href="http://211.87.224.233:18080/">http://211.87.224.233:18080/</a></p>
<p><strong>进入容器</strong></p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">docker exec -it sdu-weblab-jenkins bash</span><br></pre></td></tr></table></figure>





<h3 id="登录Jenkins"><a href="#登录Jenkins" class="headerlink" title="登录Jenkins"></a>登录Jenkins</h3><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_"># </span><span class="language-bash">查看管理员日志密码（查看文件 or 使用docker-compose logs -f 查看日志）</span></span><br><span class="line">cat data/secrets/initialAdminPassword # 可能没有文件读权限</span><br></pre></td></tr></table></figure>



<p>admin: f991e76fb99b4e3993ccdb52a9eaa8f7</p>
<h3 id="管理插件"><a href="#管理插件" class="headerlink" title="管理插件"></a>管理插件</h3><p>入口：[Manage Jenkins]-&gt;[System Configuration]-&gt;[Manage Plugins]</p>
<p><strong>必备插件</strong></p>
<ul>
<li>Git Parameter</li>
<li>Publish Over SSH</li>
<li>Gitlab</li>
<li>Pipeline</li>
</ul>
<h3 id="全局配置"><a href="#全局配置" class="headerlink" title="全局配置"></a>全局配置</h3><h4 id="Manage-Jenkins-gt-Global-Tool-Configuration"><a href="#Manage-Jenkins-gt-Global-Tool-Configuration" class="headerlink" title="[Manage Jenkins]-&gt;[Global Tool Configuration]"></a>[Manage Jenkins]-&gt;[Global Tool Configuration]</h4><p>配置jdk和maven的home。<br>其中MAVEN_HOME配置为<code>/opt/maven</code>; JAVA_HOME配置为<code>/opt/java8</code>（不错这两个文件夹其实是从宿主机映射过来的，其真实路径分别为宿主机的<code>$MAVEN_HOME</code>、<code>JAVA_HOME</code>，也就是<code>/opt/apache-maven-3.8.5</code>、<code>/usr/lib/jvm/java-8-openjdk-amd64</code>）</p>
<h4 id="Manage-Jenkins-gt-Configure-System-gt-Publish-over-SSH"><a href="#Manage-Jenkins-gt-Configure-System-gt-Publish-over-SSH" class="headerlink" title="[Manage Jenkins]-&gt;[Configure System]-&gt;[Publish over SSH]"></a>[Manage Jenkins]-&gt;[Configure System]-&gt;[Publish over SSH]</h4><p>配置远程发布的机器，这里为了方便就配置本机即可。（这里在配置auth校验的时候最好使用密码校验，配置的私钥话可能因为不合规导致失败）</p>
<h3 id="在Jenkins容器内使用docker"><a href="#在Jenkins容器内使用docker" class="headerlink" title="在Jenkins容器内使用docker"></a>在Jenkins容器内使用docker</h3><p>两种方案，一种是在Jenkins镜像里就有docker，另一种是使用宿主机的docker。</p>
<p>这里我们采取后者。</p>
<blockquote>
<p>参考 <a target="_blank" rel="noopener" href="https://www.dockone.io/article/431">https://www.dockone.io/article/431</a></p>
</blockquote>
<p>这里只讲操作不讲原因和原理。</p>
<p>第一步修改权限：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">cd /var/run</span><br><span class="line">sudo chown root:root docker.sock &amp;&amp; sudo chmod o+rw docker.sock</span><br></pre></td></tr></table></figure>



<p>第二步修改jenkins的docker-compose.yml</p>
<figure class="highlight yaml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br></pre></td><td class="code"><pre><span class="line"><span class="attr">version:</span> <span class="string">&#x27;3.6&#x27;</span></span><br><span class="line"><span class="attr">services:</span> </span><br><span class="line">  <span class="attr">jenkins:</span> </span><br><span class="line">    <span class="attr">image:</span> <span class="string">jenkins/jenkins:latest</span></span><br><span class="line">    <span class="attr">container_name:</span> <span class="string">sdu-weblab-jenkins-latest</span></span><br><span class="line">    <span class="attr">restart:</span> <span class="string">always</span></span><br><span class="line">    <span class="attr">ports:</span> </span><br><span class="line">      <span class="bullet">-</span> <span class="string">&quot;18080:8080&quot;</span></span><br><span class="line">      <span class="bullet">-</span> <span class="string">&quot;50000:50000&quot;</span></span><br><span class="line">    <span class="attr">volumes:</span> </span><br><span class="line">      <span class="bullet">-</span> <span class="string">./data:/var/jenkins_home</span> <span class="comment"># jenkins:latest 的home目录，包括插件和配置等等</span></span><br><span class="line">      <span class="bullet">-</span> <span class="string">&#x27;$MAVEN_HOME:/opt/maven&#x27;</span></span><br><span class="line">      <span class="bullet">-</span> <span class="string">&#x27;$JAVA_HOME:/opt/java8&#x27;</span></span><br><span class="line">      <span class="bullet">-</span> <span class="string">/var/run/docker.sock:/var/run/docker.sock</span></span><br><span class="line">      <span class="bullet">-</span> <span class="string">/usr/bin/docker:/usr/bin/docker</span></span><br><span class="line">      <span class="bullet">-</span> <span class="string">/etc/docker/daemon.json:/etc/docker/daemon.json</span></span><br></pre></td></tr></table></figure>

<p>重点就是挂载宿主机三个文件即可，至于这里为什么mount这三个就足够了，不做解释。</p>
<p>记住重启一下</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">docker-compose up -d</span><br></pre></td></tr></table></figure>



<p>检查：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">jsy@wzai:~$ docker exec -it a6d580bfb4e1 bash</span><br><span class="line">jenkins@a6d580bfb4e1:/$</span><br><span class="line">jenkins@a6d580bfb4e1:/$</span><br><span class="line">jenkins@a6d580bfb4e1:/$ docker version</span><br></pre></td></tr></table></figure>


<h2 id="Harbor"><a href="#Harbor" class="headerlink" title="Harbor"></a>Harbor</h2><h3 id="下载"><a href="#下载" class="headerlink" title="下载"></a>下载</h3><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">wget https://github.com/goharbor/harbor/releases/download/v2.5.0/harbor-offline-installer-v2.5.0.tgz</span><br></pre></td></tr></table></figure>



<h3 id="安装-2"><a href="#安装-2" class="headerlink" title="安装"></a>安装</h3><p><strong>解压</strong></p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">tar -xzvf harbor-offline-installer-v2.5.0.tgz -C ./</span><br></pre></td></tr></table></figure>

<p>解压结果</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">jsy@wzai:~/devops$ ls harbor/</span><br><span class="line">common.sh  harbor.v2.5.0.tar.gz  harbor.yml.tmpl  install.sh  LICENSE  prepare</span><br></pre></td></tr></table></figure>



<p><strong>编辑配置文件</strong></p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">cp harbor.yml.tmpl harbor.yml</span><br></pre></td></tr></table></figure>

<p>修改hostname为主机ip，将htts相关内容注释掉（暂时不需要使用到https）、修改admin密码、修改http端口号。</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line">hostname: 211.87.224.233</span><br><span class="line"></span><br><span class="line">http:</span><br><span class="line">  # port for http, default is 80. If https enabled, this port will redirect to https port</span><br><span class="line">  port: 8930</span><br><span class="line">  </span><br><span class="line">harbor_admin_password: admin</span><br></pre></td></tr></table></figure>




<p>安装：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">./prepare &amp;&amp; sudo ./install.sh</span><br></pre></td></tr></table></figure>



<p>install过程分为这么几步：</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">[Step 0]: checking if docker is installed ...</span><br><span class="line">[Step 1]: checking docker-compose is installed ...</span><br><span class="line">[Step 2]: loading Harbor images ...</span><br><span class="line">[Step 3]: preparing environment ...</span><br><span class="line">[Step 4]: preparing harbor configs ...</span><br></pre></td></tr></table></figure>



<p>安装完毕后检查一下：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br></pre></td><td class="code"><pre><span class="line">jsy@wzai:~/devops/harbor$ sudo docker-compose ps</span><br><span class="line">      Name                    Command                 State                  Ports</span><br><span class="line">----------------------------------------------------------------------------------------------</span><br><span class="line">harbor-core         /harbor/entrypoint.sh          Up (healthy)</span><br><span class="line">harbor-db           /docker-entrypoint.sh 96 13    Up (healthy)</span><br><span class="line">harbor-jobservice   /harbor/entrypoint.sh          Up (healthy)</span><br><span class="line">harbor-log          /bin/sh -c /usr/local/bin/     Up (healthy)   127.0.0.1:1514-&gt;10514/tcp</span><br><span class="line">                    ...</span><br><span class="line">harbor-portal       nginx -g daemon off;           Up (healthy)</span><br><span class="line">nginx               nginx -g daemon off;           Up (healthy)   0.0.0.0:8930-&gt;8080/tcp,:::89</span><br><span class="line">                                                                  30-&gt;8080/tcp</span><br><span class="line">redis               redis-server /etc/redis.conf   Up (healthy)</span><br><span class="line">registry            /home/harbor/entrypoint.sh     Up (healthy)</span><br><span class="line">registryctl         /home/harbor/start.sh          Up (healthy)</span><br></pre></td></tr></table></figure>



<p>浏览器访问检查</p>
<p>localhost:8930</p>
<h3 id="拉取-x2F-推送镜像"><a href="#拉取-x2F-推送镜像" class="headerlink" title="拉取&#x2F;推送镜像"></a>拉取&#x2F;推送镜像</h3><p>下一步使用docker login到私服，需要将私服的htp地址配置到docker的不安全register中；</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">sudo vim /etc/docker/daemon.json</span><br></pre></td></tr></table></figure>

<p>写入</p>
<figure class="highlight json"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line"><span class="punctuation">&#123;</span></span><br><span class="line">  <span class="attr">&quot;insecure-registries&quot;</span><span class="punctuation">:</span> <span class="punctuation">[</span><span class="string">&quot;211.87.224.233:8930&quot;</span><span class="punctuation">]</span></span><br><span class="line"><span class="punctuation">&#125;</span></span><br></pre></td></tr></table></figure>

<p>必须重启docker服务</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">sudo systemctl restart docker</span><br></pre></td></tr></table></figure>



<p>镜像名称要求：私服地址&#x2F;项目名&#x2F;镜像名:版本</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_"># </span><span class="language-bash">docker tag SOURCE_IMAGE[:TAG] TARGET_IMAGE[:TAG]</span></span><br><span class="line">docker tag IMAGE_ID 私服地址/项目名/镜像名:版本</span><br></pre></td></tr></table></figure>



<p><strong>举例</strong></p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">docker tag hello-world $HARBOR_URL/sdu-weblab/hello-world # 配置一下HARBOR_URL环境变量</span><br></pre></td></tr></table></figure>

<p>检查一下</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_">&gt; </span><span class="language-bash">docker images</span> </span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">211.87.224.233:8930/sdu-weblab/hello-world   latest             feb5d9fea6a5   7 months ago   13.3kB</span></span><br></pre></td></tr></table></figure>



<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_"># </span><span class="language-bash">先登录后推送</span></span><br><span class="line">docker login -u admin -p admin $HARBOR_URL</span><br><span class="line">docker push 211.87.224.233:8930/sdu-weblab/hello-world</span><br></pre></td></tr></table></figure>



<p>推送成功</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">jsy@wzai:~$ docker push 211.87.224.233:8930/sdu-weblab/hello-world</span><br><span class="line">Using default tag: latest</span><br><span class="line">The push refers to repository [211.87.224.233:8930/sdu-weblab/hello-world]</span><br><span class="line">e07ee1baac5f: Pushed</span><br><span class="line">latest: digest: sha256:f54a58bc1aac5ea1a25d796ae155dc228b3f0e11d046ae276b39c4bf2f13d8c4 size: 525</span><br></pre></td></tr></table></figure>



<p>拉取镜像也是一样的。</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_"># </span><span class="language-bash">先删除本地的</span></span><br><span class="line">docker image rm 211.87.224.233:8930/sdu-weblab/hello-world</span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">直接粘贴浏览器的命令</span></span><br><span class="line">docker pull 211.87.224.233:8930/sdu-weblab/hello-world@sha256:f54a58bc1aac5ea1a25d796ae155dc228b3f0e11d046ae276b39c4bf2f13d8c4</span><br></pre></td></tr></table></figure>

<blockquote>
<p><a target="_blank" rel="noopener" href="https://github.com/jenkinsci/docker/blob/master/README.md">https://github.com/jenkinsci/docker/blob/master/README.md</a></p>
</blockquote>

    </div>

    
    
    

    <footer class="post-footer">

        

          <div class="post-nav">
            <div class="post-nav-item">
                <a href="/2022/05/02/linux%E6%9F%A5%E7%9C%8B%E7%A1%AC%E4%BB%B6%E3%80%81%E7%B3%BB%E7%BB%9F%E4%BF%A1%E6%81%AF/" rel="prev" title="Linux查看系统信息——内存、CPU、磁盘">
                  <i class="fa fa-chevron-left"></i> Linux查看系统信息——内存、CPU、磁盘
                </a>
            </div>
            <div class="post-nav-item">
                <a href="/2022/05/07/Sdu-Devops-02/" rel="next" title="使用Jenkins的pipeline实现CI/CD">
                  使用Jenkins的pipeline实现CI/CD <i class="fa fa-chevron-right"></i>
                </a>
            </div>
          </div>
    </footer>
  </article>
</div>






</div>
  </main>

  <footer class="footer">
    <div class="footer-inner">


<div class="copyright">
  &copy; 
  <span itemprop="copyrightYear">2023</span>
  <span class="with-love">
    <i class="fa fa-heart"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">SongyangJi</span>
</div>
  <div class="powered-by">由 <a href="https://hexo.io/" rel="noopener" target="_blank">Hexo</a> & <a href="https://theme-next.js.org/muse/" rel="noopener" target="_blank">NexT.Muse</a> 强力驱动
  </div>

    </div>
  </footer>

  
  <div class="toggle sidebar-toggle" role="button">
    <span class="toggle-line"></span>
    <span class="toggle-line"></span>
    <span class="toggle-line"></span>
  </div>
  <div class="sidebar-dimmer"></div>
  <div class="back-to-top" role="button" aria-label="返回顶部">
    <i class="fa fa-arrow-up fa-lg"></i>
    <span>0%</span>
  </div>

<noscript>
  <div class="noscript-warning">Theme NexT works best with JavaScript enabled</div>
</noscript>


  
  <script src="https://cdnjs.cloudflare.com/ajax/libs/animejs/3.2.1/anime.min.js" integrity="sha256-XL2inqUJaslATFnHdJOi9GfQ60on8Wx1C2H8DYiN1xY=" crossorigin="anonymous"></script>
<script src="/js/comments.js"></script><script src="/js/utils.js"></script><script src="/js/motion.js"></script><script src="/js/schemes/muse.js"></script><script src="/js/next-boot.js"></script>

  <script src="https://cdnjs.cloudflare.com/ajax/libs/hexo-generator-searchdb/1.4.1/search.js" integrity="sha256-1kfA5uHPf65M5cphT2dvymhkuyHPQp5A53EGZOnOLmc=" crossorigin="anonymous"></script>
<script src="/js/third-party/search/local-search.js"></script>





  





</body>
</html>
